<!DOCTYPE html>
<html>
	<head>
		<!--
        	作者：刘开新
        	时间：2018-09-26
        	描述：
        -->
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
	<script type="text/javascript">
		document.write("<h3>第一题</h3>");
		//题目一
		var shu=new Array(6,5,3,7,4,2,1,1,2,3);
		var a=shu[0];
		for(var i=0;i<shu.length;i++){
			if (a<=shu[i]) {
				a=shu[i];
			}
		}
		document.write(a);
		
		document.write("<br/>"+"<h3>第二题</h3>");
		//题目二
		var shu=new Array(1,4,3,2,5,6,7,8,8,9);
		for(var i=0;i<shu.length;i++){
			if (shu[i]==5) {
				document.write("数组有5的存在");				
				break;
			}else if(i==(shu.length-1)){
				document.write("数组没有5的存在!");
			}
		}
		
		document.write("<br/>"+"<h3>第三题</h3>");
		//第三题
		var name=new Array("张三","李四","王五","赵六","钱七");
		
		var sex=new Array("女","男","女","女","女");
		var year=new Array(21,21,22,21,24);
		var nianji=new Array("大一","大一","大二","大三","大一");
		
		
		
		document.write("<br/>"+"<h3>第四题</h3>");
		for(var i=1;i<=9;i++){
			for(var j=1;j<=i;j++){
				document.write((i*j)+"&nbsp");
			}
			document.write("<br/>");
		}
		
		
		document.write("<br/>"+"<h3>第五题</h3>");
		//for写法
		var a=1,b=5;
		for(var i=1;i<=4;i++){
			
			for(var j=3;j>=i;j--){
				document.write("&nbsp");
			}
			for(var j=0;j<a;j++){
				document.write("*");
			}
			document.write("<br/>");
			a=a+2;
		}
		for(var i=1;i<=3;i++){
			for(var j=1;j<=i;j++){
				document.write("&nbsp");
			}
			for(var j=0;j<b;j++){
				document.write("*");
			}
			document.write("<br/>");
			b=b-2;
		}
		
			
		document.write("<br/>");
		//while写法
		var a=1,d=1;
		while(a<=4){
			var b=3,c=0;
			while(b>=a){
				document.write("&nbsp");
				b--;
			}
			while(c<d){
				document.write("*");
				c++	
			}
			document.write("<br/>");
			a++;
			d=d+2;
		}
		var a=1,d=5;
		while(a<=3){
			var b=1,c=0;
			while(b<=a){
				document.write("&nbsp");
				b++;
			}
			while(c<=d){
				document.write("*");
				c++;
			}
			document.write("<br/>");
			d-=2;
			a++;
		}
		
		
		document.write("<br/>"+"<h3>第六题</h3>");
		var str="48sdf41adf7df51pemix";
		var s = str.replace(/[0-9]/g,0).replace(/[a-zA-Z]/g,1);
		var m=0,n=0;
		for(var i=0,l=s.length;i<l;i++){
		   var c = s[i];
		    switch(c){
		       case '0':
		       m++;
		       break;
		       case '1':
		       n++;
		       break;
		    }
		}
		document.write(str+"<br/>"+"数字有："+m+",字母有："+n);
		
		
		document.write("<br/>"+"<h3>第七题</h3>");
		function ss(a,b,c){
			if(a>=b){
				if(a>=c){
					document.write(a);
				}else{
					document.write(c);
				}
			}else{
				if(b>=c){
					document.write(b);
				}else{
					document.write(c);
				}
			}
		}
		ss(15,50,30);
		
		
		
		document.write("<br/>"+"<h3>第八题</h3>");
		var item=new Array(1,4,3,2,5,6,7,8,8);
		for(var i=0;i<item.length;i++){
			if(item[i]==5){
				document.write("5在数组的第"+(i+1)+"个位置");
			}
		}
		
		
		document.write("<br/>"+"<h3>第九题</h3>");
		var a=0;
		for(var i=1;i<=100;i++){
			for(var j=2;j<i;j++){
				if(i%j==0){
					a=1;
					break;
				}else{
					a=0;
					}
			}
			if(a==0&&i!=1){
				document.write(i+"&nbsp");
			}
		}

		
		
		document.write("<br/>"+"<h3>第十题</h3>");
		var a=new Array(1,4,3,2,5,6,7,8,8);
		var b=new Array(1,4,2,5,8);
		for(i=(a.length-3);i<a.length;i++){
			b[b.length]=a[i];
		}
		for(i=0;i<b.length;i++){
			document.write(b[i]+"&nbsp");
		}
		
		</script>
</html>
